local sk__juelie = fk.CreateSkill {

  name = "sk__juelie",

  tags = {},

}



sk__juelie:addEffect("active", {
  name = "sk__juelie",
  anim_type = "control",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__juelie",
  can_use = function(self, player)
    return player:usedSkillTimes(sk__juelie.name, Player.HistoryPhase) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = function(self, player, to_select, selected, selected_cards)
    return #selected == 0 and to_select ~= player and
        player:getHandcardNum() ~= to_select:getHandcardNum()
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local n = player:getHandcardNum() - target:getHandcardNum()
    if n < 0 then
      n = -n
      if #room:askForDiscard(target, n, n, false, sk__juelie.name, true, ".", "#sk__juelie-discard:" .. player.id .. "::" .. n) < n then
        room:useVirtualCard("slash", nil, player, target, sk__juelie.name, true)
      end
    else
      local choice = room:askForChoice(target, { "sk__juelie_draw:::" .. n, "sk__juelie_slash:" .. player.id },
        sk__juelie.name)
      if choice[12] == "d" then
        target:drawCards(n, sk__juelie.name)
      else
        room:useVirtualCard("slash", nil, player, target, sk__juelie.name, true)
      end
    end
  end,
})

return sk__juelie
